﻿using System;
namespace Producers.Rr.Xtee.Riik.Ee.Producer.Rr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="RR52Response", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RR52Response))]
    public class RR52ResponseSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IRR52Response clazz;
        
        public RR52ResponseSerializer(IRR52Response clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("veakood");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Veakood))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("veatekst");
            if (clazz.Veatekst!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Veatekst))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Veatekst");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("isik");
            if (clazz.Isik!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute(">>>RR52Response>isik>isik", "http://producers.rr.xtee.riik.ee/producer/rr", clazz.Isik.Count);
                for (int x = 0; ((clazz.Isik != null) 
                            && (x < clazz.Isik.Count)); x = (x + 1)) {
                    if (clazz.Isik[x]!=null) {
                        Writer.WriteStartElement("isik");
                        global::Xtee.Core.SerializationMetadata metaIsik = this.GetMetaData(clazz.Isik[x]);
                        Writer.WriteTypeAttribute(metaIsik.TypeQualifiedName.Namespace, metaIsik.TypeQualifiedName.Name);
                        metaIsik.NewSerializer(clazz.Isik[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isik");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("dok");
            if (clazz.Dok!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute(">>>RR52Response>dok>dok", "http://producers.rr.xtee.riik.ee/producer/rr", clazz.Dok.Count);
                for (int x = 0; ((clazz.Dok != null) 
                            && (x < clazz.Dok.Count)); x = (x + 1)) {
                    if (clazz.Dok[x]!=null) {
                        Writer.WriteStartElement("dok");
                        global::Xtee.Core.SerializationMetadata metaDok = this.GetMetaData(clazz.Dok[x]);
                        Writer.WriteTypeAttribute(metaDok.TypeQualifiedName.Namespace, metaDok.TypeQualifiedName.Name);
                        metaDok.NewSerializer(clazz.Dok[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Dok");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("suhe");
            if (clazz.Suhe!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute(">>>RR52Response>suhe>suhe", "http://producers.rr.xtee.riik.ee/producer/rr", clazz.Suhe.Count);
                for (int x = 0; ((clazz.Suhe != null) 
                            && (x < clazz.Suhe.Count)); x = (x + 1)) {
                    if (clazz.Suhe[x]!=null) {
                        Writer.WriteStartElement("suhe");
                        global::Xtee.Core.SerializationMetadata metaSuhe = this.GetMetaData(clazz.Suhe[x]);
                        Writer.WriteTypeAttribute(metaSuhe.TypeQualifiedName.Namespace, metaSuhe.TypeQualifiedName.Name);
                        metaSuhe.NewSerializer(clazz.Suhe[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Suhe");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="veakood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR52Response>veakood");
                }
                clazz.Veakood = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("veakood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR52Response>veakood", Reader.LocalName);
            }
            if (Reader.LocalName=="veatekst") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR52Response>veatekst");
                }
                clazz.Veatekst = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("veatekst")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR52Response>veatekst", Reader.LocalName);
            }
            if (Reader.LocalName=="isik") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR52Response>isik");
                }
                clazz.Isik = new System.Collections.Generic.List<RR52Response.IIsikType>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("isik");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "isik")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>RR52Response>isik>isik");
                        }
                        global::Xtee.Core.SerializationMetadata metaIsik = this.GetMetaData<RR52Response.IIsikType>(Reader, ">>>RR52Response>isik>isik", "http://producers.rr.xtee.riik.ee/producer/rr");
                        RR52Response.IIsikType item = metaIsik.NewEntity<RR52Response.IIsikType>();
                        clazz.Isik.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("isik");
                            metaIsik.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR52Response>isik", Reader.LocalName);
            }
            if (Reader.LocalName=="dok") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR52Response>dok");
                }
                clazz.Dok = new System.Collections.Generic.List<RR52Response.IDokType>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("dok");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "dok")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>RR52Response>dok>dok");
                        }
                        global::Xtee.Core.SerializationMetadata metaDok = this.GetMetaData<RR52Response.IDokType>(Reader, ">>>RR52Response>dok>dok", "http://producers.rr.xtee.riik.ee/producer/rr");
                        RR52Response.IDokType item = metaDok.NewEntity<RR52Response.IDokType>();
                        clazz.Dok.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("dok");
                            metaDok.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR52Response>dok", Reader.LocalName);
            }
            if (Reader.LocalName=="suhe") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR52Response>suhe");
                }
                clazz.Suhe = new System.Collections.Generic.List<RR52Response.ISuheType>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("suhe");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "suhe")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>RR52Response>suhe>suhe");
                        }
                        global::Xtee.Core.SerializationMetadata metaSuhe = this.GetMetaData<RR52Response.ISuheType>(Reader, ">>>RR52Response>suhe>suhe", "http://producers.rr.xtee.riik.ee/producer/rr");
                        RR52Response.ISuheType item = metaSuhe.NewEntity<RR52Response.ISuheType>();
                        clazz.Suhe.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("suhe");
                            metaSuhe.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR52Response>suhe", Reader.LocalName);
            }
        }
        
        [global::Xtee.Core.Attributes.XmlTypeAttribute(Name=">>>RR52Response>isik>isik", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RR52Response.IsikType))]
        public class IsikTypeSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
            
            protected RR52Response.IIsikType clazz;
            
            public IsikTypeSerializer(RR52Response.IIsikType clazz) {
                this.clazz = clazz;
            }
            
            public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
                base.WriteXml(Writer);
                Writer.WriteStartElement("isik.Perenimi");
                if (clazz.IsikPerenimi!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikPerenimi))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikPerenimi");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("isik.Eesnimi");
                if (clazz.IsikEesnimi!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikEesnimi))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikEesnimi");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("isik.Sugu");
                if (clazz.IsikSugu!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikSugu))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikSugu");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("isik.Synniaeg");
                if (clazz.IsikSynniaeg!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikSynniaeg))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikSynniaeg");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("isik.Isikukood");
                if (clazz.IsikIsikukood!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikIsikukood))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikIsikukood");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("isik.Staatus");
                if (clazz.IsikStaatus!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikStaatus))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikStaatus");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("isik.Eesti_aadress");
                if (clazz.IsikEestiAadress!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikEestiAadress))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikEestiAadress");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("isik.Synnikoht");
                if (clazz.IsikSynnikoht!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikSynnikoht))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikSynnikoht");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("isik.Kodakondsus");
                if (clazz.IsikKodakondsus!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikKodakondsus))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikKodakondsus");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("isik.Perekonnaseis");
                if (clazz.IsikPerekonnaseis!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikPerekonnaseis))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikPerekonnaseis");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("isik.Teovoime");
                if (clazz.IsikTeovoime!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikTeovoime))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikTeovoime");
                }
                Writer.WriteEndElement();
            }
            
            public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
                base.ReadXml(Reader);
                if (Reader.LocalName=="isik.Perenimi") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>isik>isik>isik.Perenimi");
                    }
                    clazz.IsikPerenimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.Perenimi")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>isik>isik>isik.Perenimi", Reader.LocalName);
                }
                if (Reader.LocalName=="isik.Eesnimi") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>isik>isik>isik.Eesnimi");
                    }
                    clazz.IsikEesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.Eesnimi")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>isik>isik>isik.Eesnimi", Reader.LocalName);
                }
                if (Reader.LocalName=="isik.Sugu") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>isik>isik>isik.Sugu");
                    }
                    clazz.IsikSugu = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.Sugu")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>isik>isik>isik.Sugu", Reader.LocalName);
                }
                if (Reader.LocalName=="isik.Synniaeg") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>isik>isik>isik.Synniaeg");
                    }
                    clazz.IsikSynniaeg = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.Synniaeg")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>isik>isik>isik.Synniaeg", Reader.LocalName);
                }
                if (Reader.LocalName=="isik.Isikukood") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>isik>isik>isik.Isikukood");
                    }
                    clazz.IsikIsikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.Isikukood")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>isik>isik>isik.Isikukood", Reader.LocalName);
                }
                if (Reader.LocalName=="isik.Staatus") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>isik>isik>isik.Staatus");
                    }
                    clazz.IsikStaatus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.Staatus")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>isik>isik>isik.Staatus", Reader.LocalName);
                }
                if (Reader.LocalName=="isik.Eesti_aadress") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>isik>isik>isik.Eesti_aadress");
                    }
                    clazz.IsikEestiAadress = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.Eesti_aadress")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>isik>isik>isik.Eesti_aadress", Reader.LocalName);
                }
                if (Reader.LocalName=="isik.Synnikoht") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>isik>isik>isik.Synnikoht");
                    }
                    clazz.IsikSynnikoht = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.Synnikoht")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>isik>isik>isik.Synnikoht", Reader.LocalName);
                }
                if (Reader.LocalName=="isik.Kodakondsus") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>isik>isik>isik.Kodakondsus");
                    }
                    clazz.IsikKodakondsus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.Kodakondsus")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>isik>isik>isik.Kodakondsus", Reader.LocalName);
                }
                if (Reader.LocalName=="isik.Perekonnaseis") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>isik>isik>isik.Perekonnaseis");
                    }
                    clazz.IsikPerekonnaseis = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.Perekonnaseis")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>isik>isik>isik.Perekonnaseis", Reader.LocalName);
                }
                if (Reader.LocalName=="isik.Teovoime") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>isik>isik>isik.Teovoime");
                    }
                    clazz.IsikTeovoime = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.Teovoime")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>isik>isik>isik.Teovoime", Reader.LocalName);
                }
            }
        }
        
        [global::Xtee.Core.Attributes.XmlTypeAttribute(Name=">>>RR52Response>dok>dok", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RR52Response.DokType))]
        public class DokTypeSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
            
            protected RR52Response.IDokType clazz;
            
            public DokTypeSerializer(RR52Response.IDokType clazz) {
                this.clazz = clazz;
            }
            
            public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
                base.WriteXml(Writer);
                Writer.WriteStartElement("dok.DokTyyp");
                if (clazz.DokDokTyyp!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.DokDokTyyp))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : DokDokTyyp");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("dok.DokSeeria");
                if (clazz.DokDokSeeria!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.DokDokSeeria))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : DokDokSeeria");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("dok.DokNr");
                if (clazz.DokDokNr!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.DokDokNr))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : DokDokNr");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("dok.DokAsutusRiik");
                if (clazz.DokDokAsutusRiik!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.DokDokAsutusRiik))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : DokDokAsutusRiik");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("dok.DokAsutus");
                if (clazz.DokDokAsutus!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.DokDokAsutus))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : DokDokAsutus");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("dok.DokValjastamisKuup");
                if (clazz.DokDokValjastamisKuup!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.DokDokValjastamisKuup))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : DokDokValjastamisKuup");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("dok.DokKehtAlgus");
                if (clazz.DokDokKehtAlgus!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.DokDokKehtAlgus))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : DokDokKehtAlgus");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("dok.DokKehtLopp");
                if (clazz.DokDokKehtLopp!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.DokDokKehtLopp))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : DokDokKehtLopp");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("dok.DokStaatus");
                if (clazz.DokDokStaatus!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.DokDokStaatus))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : DokDokStaatus");
                }
                Writer.WriteEndElement();
            }
            
            public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
                base.ReadXml(Reader);
                if (Reader.LocalName=="dok.DokTyyp") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>dok>dok>dok.DokTyyp");
                    }
                    clazz.DokDokTyyp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("dok.DokTyyp")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>dok>dok>dok.DokTyyp", Reader.LocalName);
                }
                if (Reader.LocalName=="dok.DokSeeria") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>dok>dok>dok.DokSeeria");
                    }
                    clazz.DokDokSeeria = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("dok.DokSeeria")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>dok>dok>dok.DokSeeria", Reader.LocalName);
                }
                if (Reader.LocalName=="dok.DokNr") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>dok>dok>dok.DokNr");
                    }
                    clazz.DokDokNr = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("dok.DokNr")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>dok>dok>dok.DokNr", Reader.LocalName);
                }
                if (Reader.LocalName=="dok.DokAsutusRiik") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>dok>dok>dok.DokAsutusRiik");
                    }
                    clazz.DokDokAsutusRiik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("dok.DokAsutusRiik")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>dok>dok>dok.DokAsutusRiik", Reader.LocalName);
                }
                if (Reader.LocalName=="dok.DokAsutus") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>dok>dok>dok.DokAsutus");
                    }
                    clazz.DokDokAsutus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("dok.DokAsutus")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>dok>dok>dok.DokAsutus", Reader.LocalName);
                }
                if (Reader.LocalName=="dok.DokValjastamisKuup") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>dok>dok>dok.DokValjastamisKuup");
                    }
                    clazz.DokDokValjastamisKuup = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("dok.DokValjastamisKuup")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>dok>dok>dok.DokValjastamisKuup", Reader.LocalName);
                }
                if (Reader.LocalName=="dok.DokKehtAlgus") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>dok>dok>dok.DokKehtAlgus");
                    }
                    clazz.DokDokKehtAlgus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("dok.DokKehtAlgus")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>dok>dok>dok.DokKehtAlgus", Reader.LocalName);
                }
                if (Reader.LocalName=="dok.DokKehtLopp") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>dok>dok>dok.DokKehtLopp");
                    }
                    clazz.DokDokKehtLopp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("dok.DokKehtLopp")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>dok>dok>dok.DokKehtLopp", Reader.LocalName);
                }
                if (Reader.LocalName=="dok.DokStaatus") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>dok>dok>dok.DokStaatus");
                    }
                    clazz.DokDokStaatus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("dok.DokStaatus")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>dok>dok>dok.DokStaatus", Reader.LocalName);
                }
            }
        }
        
        [global::Xtee.Core.Attributes.XmlTypeAttribute(Name=">>>RR52Response>suhe>suhe", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RR52Response.SuheType))]
        public class SuheTypeSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
            
            protected RR52Response.ISuheType clazz;
            
            public SuheTypeSerializer(RR52Response.ISuheType clazz) {
                this.clazz = clazz;
            }
            
            public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
                base.WriteXml(Writer);
                Writer.WriteStartElement("suhe.Suhtetyyp");
                if (clazz.SuheSuhtetyyp!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SuheSuhtetyyp))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SuheSuhtetyyp");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("suhe.Isikukood");
                if (clazz.SuheIsikukood!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SuheIsikukood))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SuheIsikukood");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("suhe.Perenimi");
                if (clazz.SuhePerenimi!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SuhePerenimi))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SuhePerenimi");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("suhe.Eesnimi");
                if (clazz.SuheEesnimi!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SuheEesnimi))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SuheEesnimi");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("suhe.Isanimi");
                if (clazz.SuheIsanimi!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SuheIsanimi))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SuheIsanimi");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("suhe.Eesti_aadress");
                if (clazz.SuheEestiAadress!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SuheEestiAadress))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SuheEestiAadress");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("suhe.Synnikoht");
                if (clazz.SuheSynnikoht!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SuheSynnikoht))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SuheSynnikoht");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("suhe.IsikuStaatus");
                if (clazz.SuheIsikuStaatus!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SuheIsikuStaatus))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SuheIsikuStaatus");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("suhe.Staatus");
                if (clazz.SuheStaatus!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SuheStaatus))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SuheStaatus");
                }
                Writer.WriteEndElement();
            }
            
            public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
                base.ReadXml(Reader);
                if (Reader.LocalName=="suhe.Suhtetyyp") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>suhe>suhe>suhe.Suhtetyyp");
                    }
                    clazz.SuheSuhtetyyp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("suhe.Suhtetyyp")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>suhe>suhe>suhe.Suhtetyyp", Reader.LocalName);
                }
                if (Reader.LocalName=="suhe.Isikukood") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>suhe>suhe>suhe.Isikukood");
                    }
                    clazz.SuheIsikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("suhe.Isikukood")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>suhe>suhe>suhe.Isikukood", Reader.LocalName);
                }
                if (Reader.LocalName=="suhe.Perenimi") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>suhe>suhe>suhe.Perenimi");
                    }
                    clazz.SuhePerenimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("suhe.Perenimi")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>suhe>suhe>suhe.Perenimi", Reader.LocalName);
                }
                if (Reader.LocalName=="suhe.Eesnimi") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>suhe>suhe>suhe.Eesnimi");
                    }
                    clazz.SuheEesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("suhe.Eesnimi")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>suhe>suhe>suhe.Eesnimi", Reader.LocalName);
                }
                if (Reader.LocalName=="suhe.Isanimi") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>suhe>suhe>suhe.Isanimi");
                    }
                    clazz.SuheIsanimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("suhe.Isanimi")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>suhe>suhe>suhe.Isanimi", Reader.LocalName);
                }
                if (Reader.LocalName=="suhe.Eesti_aadress") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>suhe>suhe>suhe.Eesti_aadress");
                    }
                    clazz.SuheEestiAadress = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("suhe.Eesti_aadress")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>suhe>suhe>suhe.Eesti_aadress", Reader.LocalName);
                }
                if (Reader.LocalName=="suhe.Synnikoht") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>suhe>suhe>suhe.Synnikoht");
                    }
                    clazz.SuheSynnikoht = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("suhe.Synnikoht")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>suhe>suhe>suhe.Synnikoht", Reader.LocalName);
                }
                if (Reader.LocalName=="suhe.IsikuStaatus") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>suhe>suhe>suhe.IsikuStaatus");
                    }
                    clazz.SuheIsikuStaatus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("suhe.IsikuStaatus")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>suhe>suhe>suhe.IsikuStaatus", Reader.LocalName);
                }
                if (Reader.LocalName=="suhe.Staatus") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR52Response>suhe>suhe>suhe.Staatus");
                    }
                    clazz.SuheStaatus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("suhe.Staatus")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR52Response>suhe>suhe>suhe.Staatus", Reader.LocalName);
                }
            }
        }
    }
}
